package leecode;

/**
 * @author csp 2021-04-23
 */
public class Question11 {
    public static void main(String[] args) {
        Question11 question = new Question11();
        System.out.println(question.maxArea(new int[]{1, 2, 3, 45}));
    }

    //解题思路
    //两高度间的较小值*x轴差最大
    //双指针，取出每次遍历的最大值，再比较
    public int maxArea(int[] height) {
        int max = 0;
        if (height.length == 0) {
            return max;
        }
        if (height.length == 1) {
            return max;
        }
        for (int i = 0; i < height.length-1; i++) {
            for (int j = i + 1; j < height.length; j++) {
                int min = Math.min(height[i], height[j]);
                int temp = (j - i) * min;
                max = Math.max(temp, max);
            }
        }
        return max;

    }
}
